package com.prtek.reminder.bean;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Copyright (C) ShenZhen Prtek Ltd. Author Jarly Version V Created on
 * 2017/9/11.
 */

public class User implements Parcelable {

  private long userId;

  private String name;

  private String nickName;

  private int age;

  private String sex;

  private byte[] image;

  private boolean selected;

  public long getUserId() {
    return userId;
  }

  public void setUserId(long userId) {
    this.userId = userId;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public String getNickName() {
    return nickName;
  }

  public void setNickName(String nickName) {
    this.nickName = nickName;
  }

  public int getAge() {
    return age;
  }

  public void setAge(int age) {
    this.age = age;
  }

  public String getSex() {
    return sex;
  }

  public void setSex(String sex) {
    this.sex = sex;
  }

  public byte[] getImage() {
    return image;
  }

  public void setImage(byte[] image) {
    this.image = image;
  }

  public boolean isSelected() {
    return selected;
  }

  public void setSelected(boolean selected) {
    this.selected = selected;
  }

  public static Creator<User> getCREATOR() {
    return CREATOR;
  }

  @Override public int describeContents() {
    return 0;
  }

  @Override public void writeToParcel(Parcel dest, int flags) {
    dest.writeLong(this.userId);
    dest.writeString(this.name);
    dest.writeString(this.nickName);
    dest.writeInt(this.age);
    dest.writeString(this.sex);
    dest.writeByteArray(this.image);
    dest.writeByte(this.selected ? (byte) 1 : (byte) 0);
  }

  public User() {
  }

  protected User(Parcel in) {
    this.userId = in.readLong();
    this.name = in.readString();
    this.nickName = in.readString();
    this.age = in.readInt();
    this.sex = in.readString();
    this.image = in.createByteArray();
    this.selected = in.readByte() != 0;
  }

  public static final Parcelable.Creator<User> CREATOR = new Parcelable.Creator<User>() {
    @Override public User createFromParcel(Parcel source) {
      return new User(source);
    }

    @Override public User[] newArray(int size) {
      return new User[size];
    }
  };

  @Override public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    User user = (User) o;
    return userId == user.userId;
  }
}
